package com.hdax.utils;

import lombok.Builder;
import lombok.Data;

/**
 * 结果工具
 *
 * @author Aizen
 * @date 2022/05/12
 */
@Data
public class ResultUtil {

    private Integer count;
    private Object data;
    private String msg;
    private Integer code;

    public static ResultUtil result(Object data){
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.code = 0;
        resultUtil.data = data;
        resultUtil.msg = "";
        return resultUtil;
    }

    public static ResultUtil upDataResult(String msg){
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.data = "success";
        resultUtil.code = 0;
        resultUtil.msg = msg;
        return resultUtil;
    }
    public static ResultUtil updataResult2(String msg,Integer code){
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.code = code;
        resultUtil.msg = msg;
        return resultUtil;
    }

    /**
     * 分页
     * @param data 数据
     * @param count 条数
     * @return
     */
    public static ResultUtil splitPage(Object data,Integer count){
        ResultUtil result = new ResultUtil();
        result.data = data;
        result.count = count;
        result.code = 0;
        result.msg = "";
        return result;
    }

}
